package com.example.mbl.controller;

import com.example.mbl.entity.Event;
import com.example.mbl.interceptor.AppToken;
import com.example.mbl.result.PageResult;
import com.example.mbl.result.WebRestResult;
import com.example.mbl.result.business.EventPageResult;
import com.example.mbl.result.business.EventResult;
import com.example.mbl.service.EventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("Event")
public class EventController {
    @Autowired
    private EventService eventService;

    @AppToken
    @PostMapping("addEvent")
    public WebRestResult addEvent(@RequestBody Event event){
        WebRestResult result = eventService.addEVent(event);
        return result;
    }

    @AppToken
    @PostMapping("deleteEvent")
    public WebRestResult deleteEvent(@RequestBody Event event){
        WebRestResult result = eventService.deleteEvent(event);
        return result;
    }

    @AppToken
    @PostMapping("updateEvent")
    public WebRestResult updateEvent(@RequestBody Event event){
        WebRestResult result = eventService.updateEvent(event);
        return result;
    }

    @AppToken
    @PostMapping("setEventVisible")
    public WebRestResult setEventVisible(@RequestBody Event event){
        WebRestResult result = eventService.setEventVisible(event);
        return result;
    }

    @GetMapping("getEventList")
    public PageResult<EventPageResult> getEventList(String eventtitle,String eventdate,String eventtype,int page,int pagesize,String eventday){
        PageResult<EventPageResult> result = eventService.getEventList(eventtitle,eventdate,eventtype,page,pagesize,eventday);
        return result;
    }

    @GetMapping("getEventItem")
    public EventResult getEventItem(String eventid){
        EventResult result = eventService.getEventItem(eventid);
        return result;
    }
}
